/******************************************************************************/
/*                                                                            */
/*  Copyright (c) 2009: ngi-central.org                                       */
/*  All rights reserved.                                                      */
/*                                                                            */
/******************************************************************************/


#include <boost/test/unit_test.hpp>

#include "..\..\include\sgl\normalized_moments.h"

BOOST_AUTO_TEST_SUITE( normalized_moments )


BOOST_AUTO_TEST_CASE( normalized_moments__default_constructor )
{
	sgl::normalized_moments<> a;

	BOOST_CHECK( a.m00() == 0 );
	BOOST_CHECK( a.nm10() == 0 );
	BOOST_CHECK( a.nm01() == 0 );
	BOOST_CHECK( a.nm20() == 0 );
	BOOST_CHECK( a.nm11() == 0 );
	BOOST_CHECK( a.nm02() == 0 );
	BOOST_CHECK( a.nm30() == 0 );
	BOOST_CHECK( a.nm21() == 0 );
	BOOST_CHECK( a.nm12() == 0 );
	BOOST_CHECK( a.nm03() == 0 );

	sgl::normalized_moments<> b(1, 1, 2, 3, 4, 5, 6, 7, 8, 9);

	BOOST_CHECK( b.m00() == 1 );
	BOOST_CHECK( b.nm10() == 1 );
	BOOST_CHECK( b.nm01() == 2 );
	BOOST_CHECK( b.nm20() == 3 );
	BOOST_CHECK( b.nm11() == 4 );
	BOOST_CHECK( b.nm02() == 5 );
	BOOST_CHECK( b.nm30() == 6 );
	BOOST_CHECK( b.nm21() == 7 );
	BOOST_CHECK( b.nm12() == 8 );
	BOOST_CHECK( b.nm03() == 9 );
}

BOOST_AUTO_TEST_CASE( normalized_moments__copy_constructor )
{
	sgl::normalized_moments<> a(
		sgl::normalized_moments<>(1, 1, 2, 3, 4, 5, 6, 7, 8, 9));

	BOOST_CHECK( a.m00() == 1 );
	BOOST_CHECK( a.nm10() == 1 );
	BOOST_CHECK( a.nm01() == 2 );
	BOOST_CHECK( a.nm20() == 3 );
	BOOST_CHECK( a.nm11() == 4 );
	BOOST_CHECK( a.nm02() == 5 );
	BOOST_CHECK( a.nm30() == 6 );
	BOOST_CHECK( a.nm21() == 7 );
	BOOST_CHECK( a.nm12() == 8 );
	BOOST_CHECK( a.nm03() == 9 );
}

BOOST_AUTO_TEST_CASE( normalized_moments__conversion_copy_constructor )
{
	sgl::normalized_moments<> a(
		sgl::unnormalized_moments<>(1, 1, 2, 3, 4, 5, 6, 7, 8, 9));

	BOOST_CHECK( a.m00() == 1 );
	BOOST_CHECK( a.nm10() == 1 );
	BOOST_CHECK( a.nm01() == 2 );
	BOOST_CHECK( a.nm20() == 3 );
	BOOST_CHECK( a.nm11() == 4 );
	BOOST_CHECK( a.nm02() == 5 );
	BOOST_CHECK( a.nm30() == 6 );
	BOOST_CHECK( a.nm21() == 7 );
	BOOST_CHECK( a.nm12() == 8 );
	BOOST_CHECK( a.nm03() == 9 );
}

BOOST_AUTO_TEST_CASE( normalized_moments__copy_assignment )
{
	sgl::normalized_moments<> a;
	a = sgl::normalized_moments<>(1, 1, 2, 3, 4, 5, 6, 7, 8, 9);

	BOOST_CHECK( a.m00() == 1 );
	BOOST_CHECK( a.nm10() == 1 );
	BOOST_CHECK( a.nm01() == 2 );
	BOOST_CHECK( a.nm20() == 3 );
	BOOST_CHECK( a.nm11() == 4 );
	BOOST_CHECK( a.nm02() == 5 );
	BOOST_CHECK( a.nm30() == 6 );
	BOOST_CHECK( a.nm21() == 7 );
	BOOST_CHECK( a.nm12() == 8 );
	BOOST_CHECK( a.nm03() == 9 );
}

BOOST_AUTO_TEST_CASE( normalized_moments__swap )
{
	sgl::normalized_moments<> a(
		sgl::normalized_moments<>(1, 1, 2, 3, 4, 5, 6, 7, 8, 9));
	sgl::normalized_moments<> b;

	a.swap(b);

	BOOST_CHECK( a.m00() == 0 );
	BOOST_CHECK( a.nm10() == 0 );
	BOOST_CHECK( a.nm01() == 0 );
	BOOST_CHECK( a.nm20() == 0 );
	BOOST_CHECK( a.nm11() == 0 );
	BOOST_CHECK( a.nm02() == 0 );
	BOOST_CHECK( a.nm30() == 0 );
	BOOST_CHECK( a.nm21() == 0 );
	BOOST_CHECK( a.nm12() == 0 );
	BOOST_CHECK( a.nm03() == 0 );
	BOOST_CHECK( b.m00() == 1 );
	BOOST_CHECK( b.nm10() == 1 );
	BOOST_CHECK( b.nm01() == 2 );
	BOOST_CHECK( b.nm20() == 3 );
	BOOST_CHECK( b.nm11() == 4 );
	BOOST_CHECK( b.nm02() == 5 );
	BOOST_CHECK( b.nm30() == 6 );
	BOOST_CHECK( b.nm21() == 7 );
	BOOST_CHECK( b.nm12() == 8 );
	BOOST_CHECK( b.nm03() == 9 );

	b.swap(a);

	BOOST_CHECK( a.m00() == 1 );
	BOOST_CHECK( a.nm10() == 1 );
	BOOST_CHECK( a.nm01() == 2 );
	BOOST_CHECK( a.nm20() == 3 );
	BOOST_CHECK( a.nm11() == 4 );
	BOOST_CHECK( a.nm02() == 5 );
	BOOST_CHECK( a.nm30() == 6 );
	BOOST_CHECK( a.nm21() == 7 );
	BOOST_CHECK( a.nm12() == 8 );
	BOOST_CHECK( a.nm03() == 9 );
	BOOST_CHECK( b.m00() == 0 );
	BOOST_CHECK( b.nm10() == 0 );
	BOOST_CHECK( b.nm01() == 0 );
	BOOST_CHECK( b.nm20() == 0 );
	BOOST_CHECK( b.nm11() == 0 );
	BOOST_CHECK( b.nm02() == 0 );
	BOOST_CHECK( b.nm30() == 0 );
	BOOST_CHECK( b.nm21() == 0 );
	BOOST_CHECK( b.nm12() == 0 );
	BOOST_CHECK( b.nm03() == 0 );
}

BOOST_AUTO_TEST_CASE( normalized_moments__m00 )
{
	sgl::normalized_moments<> a;

	BOOST_CHECK( a.m00() == 0 );

	a.m00() = 1;

	BOOST_CHECK( a.m00() == 1 );
}

BOOST_AUTO_TEST_CASE( normalized_moments__nm10 )
{
	sgl::normalized_moments<> a;

	BOOST_CHECK( a.nm10() == 0 );

	a.nm10() = 1;

	BOOST_CHECK( a.nm10() == 1 );
}

BOOST_AUTO_TEST_CASE( normalized_moments__nm01 )
{
	sgl::normalized_moments<> a;

	BOOST_CHECK( a.nm01() == 0 );

	a.nm01() = 1;

	BOOST_CHECK( a.nm01() == 1 );
}

BOOST_AUTO_TEST_CASE( normalized_moments__nm20 )
{
	sgl::normalized_moments<> a;

	BOOST_CHECK( a.nm20() == 0 );

	a.nm20() = 1;

	BOOST_CHECK( a.nm20() == 1 );
}

BOOST_AUTO_TEST_CASE( normalized_moments__nm11 )
{
	sgl::normalized_moments<> a;

	BOOST_CHECK( a.nm11() == 0 );

	a.nm11() = 1;

	BOOST_CHECK( a.nm11() == 1 );
}

BOOST_AUTO_TEST_CASE( normalized_moments__nm02 )
{
	sgl::normalized_moments<> a;

	BOOST_CHECK( a.nm02() == 0 );

	a.nm02() = 1;

	BOOST_CHECK( a.nm02() == 1 );
}

BOOST_AUTO_TEST_CASE( normalized_moments__nm30 )
{
	sgl::normalized_moments<> a;

	BOOST_CHECK( a.nm30() == 0 );

	a.nm30() = 1;

	BOOST_CHECK( a.nm30() == 1 );
}

BOOST_AUTO_TEST_CASE( normalized_moments__nm21 )
{
	sgl::normalized_moments<> a;

	BOOST_CHECK( a.nm21() == 0 );

	a.nm21() = 1;

	BOOST_CHECK( a.nm21() == 1 );
}

BOOST_AUTO_TEST_CASE( normalized_moments__nm12 )
{
	sgl::normalized_moments<> a;

	BOOST_CHECK( a.nm12() == 0 );

	a.nm12() = 1;

	BOOST_CHECK( a.nm12() == 1 );
}

BOOST_AUTO_TEST_CASE( normalized_moments__nm03)
{
	sgl::normalized_moments<> a;

	BOOST_CHECK( a.nm03() == 0 );

	a.nm03() = 1;

	BOOST_CHECK( a.nm03() == 1 );
}

BOOST_AUTO_TEST_CASE( normalized_moments__operator_equality )
{
	sgl::normalized_moments<> a;
	sgl::normalized_moments<> b;

	BOOST_CHECK( a == b );

	sgl::normalized_moments<> c(1, 1, 2, 3, 4, 5, 6, 7, 8, 9);
	sgl::normalized_moments<> d(1, 1, 2, 3, 4, 5, 6, 7, 8, 9);

	BOOST_CHECK( c == d );
}

BOOST_AUTO_TEST_CASE( normalized_moments__operator_inequality )
{
	sgl::normalized_moments<> a;
	sgl::normalized_moments<> b(1, 1, 2, 3, 4, 5, 6, 7, 8, 9);

	BOOST_CHECK( a != b );
}

BOOST_AUTO_TEST_CASE( normalized_moments__calculate_mu20 )
{
	sgl::normalized_moments<> a(1, 1, 2, 3, 4, 5, 6, 7, 8, 9);

	BOOST_CHECK( a.calculate_mu20() == 2 );
}

BOOST_AUTO_TEST_CASE( normalized_moments__calculate_mu11 )
{
	sgl::normalized_moments<> a(1, 1, 2, 3, 4, 5, 6, 7, 8, 9);

	BOOST_CHECK( a.calculate_mu11() == 2 );
}

BOOST_AUTO_TEST_CASE( normalized_moments__calculate_mu02 )
{
	sgl::normalized_moments<> a(1, 1, 2, 3, 4, 5, 6, 7, 8, 9);

	BOOST_CHECK( a.calculate_mu02() == 1 );
}

BOOST_AUTO_TEST_CASE( normalized_moments__calculate_mu30 )
{
	sgl::normalized_moments<> a(1, 1, 2, 3, 4, 5, 6, 7, 8, 9);

	BOOST_CHECK( a.calculate_mu30() == -1 );
}

BOOST_AUTO_TEST_CASE( normalized_moments__calculate_mu21 )
{
	sgl::normalized_moments<> a(1, 1, 2, 3, 4, 5, 6, 7, 8, 9);

	BOOST_CHECK( a.calculate_mu21() == -3 );
}

BOOST_AUTO_TEST_CASE( normalized_moments__calculate_mu12 )
{
	sgl::normalized_moments<> a(1, 1, 2, 3, 4, 5, 6, 7, 8, 9);

	BOOST_CHECK( a.calculate_mu12() == -5 );
}

BOOST_AUTO_TEST_CASE( normalized_moments__calculate_mu03 )
{
	sgl::normalized_moments<> a(1, 1, 2, 3, 4, 5, 6, 7, 8, 9);

	BOOST_CHECK( a.calculate_mu03() == -5 );
}

BOOST_AUTO_TEST_SUITE_END()

